package com.zl.quickdoc.resolver.converter.impl;

import com.zl.quickdoc.constant.QuickDocC;
import com.zl.quickdoc.resolver.converter.AbstractJavaDocTag;

/**
 * 针对@dataType的转换器
 * @author zhouliang
 *
 */
public class DataTypeTagConverter extends DefaultStringParserTagConverterImpl {

    @SuppressWarnings("unchecked")
    @Override
    public AbstractJavaDocTag<String> converter(String comments) {
        AbstractJavaDocTag<String> docTag = super.converter(comments);
        String val = docTag.getValues();
        return new DataTypeTagImpl(docTag.getTagName(), val);
    }
    
    public class DataTypeTagImpl extends AbstractJavaDocTag<String> {
        /**
         * 类型值
         */
        private String value;

        public DataTypeTagImpl(String tagName, String value) {
            super(tagName);
            this.value = value;
        }

        @Override
        public String getValues() {
            if(QuickDocC.SIMPLE_TYPE_JSON.equalsIgnoreCase(this.value)){
                return QuickDocC.TYPE_JSON;
            }
            else if(QuickDocC.SIMPLE_TYPE_STREAM.equalsIgnoreCase(this.value)){
                return QuickDocC.TYPE_STREAM;
            }
            else if(QuickDocC.SIMPLE_TYPE_HTML.equalsIgnoreCase(this.value)){
                return QuickDocC.TYPE_HTML;
            }
            else if(QuickDocC.SIMPLE_TYPE_XML.equalsIgnoreCase(this.value)){
                return QuickDocC.TYPE_XML;
            }
            return this.value;
        }

    }
}
